import mmh3
import requests
import base64

def getfaviconhash(url):
    """TODO: 应该获取/favicon.ico"""
    try:
        response = requests.get(url)
        if 'image' in response.headers['Content-Type']:
            favicon = response.content
            favicon = base64.b64encode(favicon)
            hash = mmh3.hash(favicon)
        else:
            hash = None
    except Exception as e:
        print("[!] Request Error")
        print(e)
        hash = None
    return hash
